Xbasic

SYS_SHELL_WAIT Function

Syntax

V sys_shell_wait(C command_line [,L show_window [, N timeout [, L terminateOnTimeout]]])

Arguments

command_lineCharacter

The Windows command that you wish to run.

show_windowLogical

Default = .T. If .T., Display window. If .F., Hide window.

timeoutNumeric

Default = -1. Length in milliseconds to wait before timing out. -1 = INFINITE.

terminateOnTimeoutLogical

Default = .F.. If a timeout occurs and this parameter is set to true, the created process will be terminated using a pattern that injects a thread into the new process and calls Exit Process. This is to prevent handles from remaining locked. Kill process (TerminateProcess()) does not release handles gracefully.

Description

Run a program and wait until the program closes before returning.

Discussion

The SYS_SHELL_WAIT() function runs a command and waits until it is completed before returning control to Alpha Anywhere.

Example

sys_shell_wait("explorer.exe", .T.)

When used in web or mobile applications, you cannot run any programs with SYS_SHELL_WAIT() that require user input. SYS_SHELL_WAIT() is executed on the Application Server in web and mobile applications, and the user cannot interact with the script.

Here is the code for using the DOS XCopy function to copy the contents of c:\alpha\newha\Practice Before Multiple States\*.* to c:\alpha\newha\test33\*.*.

sys_shell_wait("xcopy c:\alpha\newha\Practic~\*.* c:\alpha\newha\test34\*.* /E /Y",.t.)

The following example demonstrates using the timeout and terminateOnTimeout parameters:

SYS_SHELL_WAIT("CMD.EXE /C \"DIR C:\*.* /s\"", .t.,1000,.t.)
SYS_SHELL_WAIT() does not throw any errors if something fails.

See Also